clear all
load ParEst_eh1_time0_Mex
load ParEst_eh1_time0_Mex_all_boots
load ParEst_eh1_time1_Mex
load ParEst_eh1_time1_Mex_all_boots

ParEst_eh1_time0_Mex_all_boots(:,21)=10.^ParEst_eh1_time0_Mex_all_boots(:,21);

Par1 = [ParEst_eh1_time0_Mex,ParEst_eh1_time1_Mex]'; % estimates
Par2 = [std(ParEst_eh1_time0_Mex_all_boots(:,1:end-1)),std(ParEst_eh1_time1_Mex_all_boots(:,1:end-1))]'; % bootstrap estimates

Par1(21) = 10^(Par1(21)); 
Par1(22:24) = Par1(22:24)*1000;
Par1(25) = 500*Par1(25);
Par2(22:24) = Par2(22:24)*1000;
Par2(25) = 500*Par2(25);

alphaf=Par1(17);
betaf=Par1(18);
alphai=Par1(19);
betai=Par1(20);
theta=Par1(21);
a=Par1(22);
b1 = Par1(23); 
b2 = Par1(24);
gamma = Par1(25);
alphaf_2=Par1(26);
betaf_2=Par1(27);
alphai_2=Par1(28);
betai_2=Par1(29);

sd_alphaf=Par2(17);
sd_betaf=Par2(18);
sd_alphai=Par2(19);
sd_betai=Par2(20);
sd_theta=Par2(21);
sd_a=Par2(22);
sd_b1 = Par2(23); 
sd_b2 = Par2(24);
sd_gamma = Par2(25);
sd_alphaf_2=Par2(26);
sd_betaf_2=Par2(27);
sd_alphai_2=Par2(28);
sd_betai_2=Par2(29);

load MWP_a MWP_a
load MWP_gamma MWP_gamma
load MWP_a_boot MWP_a_boot
load MWP_gamma_boot MWP_gamma_boot
sd_MWP_a=std(MWP_a_boot);
sd_MWP_gamma=std(MWP_gamma_boot);

%Contact rates
Transitions_both = {'F-N';''; 'I-N';''; 'N-F';''; 'N-I';''; 'F-I';''; 'I-F';''; 'p1';''; 'q1';'';''; 'F-N';''; 'I-N';''; 'N-F';''; 'N-I';''; 'F-I';''; 'I-F';''; 'p2';''; 'q2';''};
Estimates = [Par1(1); Par2(1); Par1(2); Par2(2); Par1(3); Par2(3); Par1(4); Par2(4); Par1(5); Par2(5); Par1(6); Par2(6); Par1(13); Par2(13); Par1(14); Par2(14);NaN;Par1(7); Par2(7); Par1(8); Par2(8); Par1(9); Par2(9); Par1(10); Par2(10); Par1(11); Par2(11); Par1(12); Par2(12); Par1(15); Par2(15); Par1(16); Par2(16)];
Transition_Rates_table = table(Transitions_both, Estimates);
writetable(Transition_Rates_table, 'Transition_Rates_table.xls')

%Preference parameters
Preference = {'theta';'';'b1';'';'b2';'';'a';'';'gamma';'';'MWP a';'';'MWP gamma';''};
Estimates = [theta; sd_theta; b1; sd_b1; b2; sd_b2; a; sd_a; gamma; sd_gamma; MWP_a; sd_MWP_a; MWP_gamma; sd_MWP_gamma];
Preferences_table = table(Preference, Estimates);
writetable(Preferences_table, 'Preferences_table.xls')

%Wage offer parameters
Wage_offer = {'alpha_formal';'';'beta_formal';'';'alpha_informal';'';'beta_informal';''};
Estimates = [alphaf; sd_alphaf; betaf; sd_betaf; alphai; sd_alphai; betai; sd_betai];
Wage_offer_par_table = table(Wage_offer, Estimates);
writetable(Wage_offer_par_table, 'Wage_offer_par_table.xls')

%Wage offer parameters
Wage_offer = {'alpha_formal';'';'beta_formal';'';'alpha_informal';'';'beta_informal';''};
Estimates = [alphaf_2; sd_alphaf_2; betaf_2; sd_betaf_2; alphai_2; sd_alphai_2; betai_2; sd_betai_2];
Wage_offer_par_table = table(Wage_offer, Estimates);
writetable(Wage_offer_par_table, 'Wage_offer_par_table_2nd_stage.xls')
